PROC FCMP User-Defined Functions by Troy Martin Hughes
Author:Troy Martin Hughes
Language: eng
Format: epub
Publisher: SAS Institute
Note the simplicity of the functional approach to multivariable initialization. A single, unassuming line of code delivers equivalent functionality to two SORT procedures and a DATA step, or to a SQL procedure having several lines of code! Thus, the exceptional speed of in-memory hash lookups has been encapsulated within the subroutine implementation, which yields a more concise, readable DATA step.
Counting Hash Keys
In previous examples, the role of a hash object has been to confirm that a key exists inside a hash object, or to return associated values when a key exists. Hash objects can also be used, however, to count keys. By incrementing a specific keyâs count each time it is encountered (that is, passed as an argument to the function instantiating the hash object), a hash object can operationalize a frequency table.
DATA step hash functionality provides the built-in hash SUM method and the associated DECLARE statement SUMINC argument, which in combination can be used to build frequency table hash objects. Unfortunately, neither the SUM method nor the SUMINC argument are supported by FCMP hash functionality. Fortunately, equivalent functionality can be engineered within the FCMP procedure from more basic hash building blocks.
For example, consider the requirement to evaluate word frequency in the Gettysburg Address, and more specifically, to find the modal wordâthe most frequently occurring word in the speech. Program 4.20 creates the Gettys data set in which the Text variable holds the text of the Gettysburg Address.
Program 4.20: Gettysburg Address
data gettys;
length text $10000;
text="Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate â we can not consecrate â we can not hallow â this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us â that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion â that we here highly resolve that these dead shall not have died in vain â that this nation, under God, shall have a new birth
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5967)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3445)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(3216)
TCP IP by Todd Lammle(2646)
Drawing Shortcuts: Developing Quick Drawing Skills Using Today's Technology by Leggitt Jim(2537)
Pandas Cookbook by Theodore Petrou(2508)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2486)
Supercharging Productivity with Trello by Brittany Joiner(2467)
Design Made Easy with Inkscape by Christopher Rogers(2323)
Mastering Tableau 2023 - Fourth Edition by Marleen Meier(2193)
Learn Qt 5: Build modern, responsive cross-platform desktop applications with Qt, C++, and QML by Nicholas Sherriff(2183)
40 Algorithms Every Programmer Should Know by Imran Ahmad(2165)
Build Stunning Real-time VFX with Unreal Engine 5 by Hrishikesh Andurlekar(2097)
Inkscape by Example by István Szép(2054)
Fusion 360 for Makers by Lydia Sloan Cline(1989)
Customizing Microsoft Teams by Gopi Kondameda(1901)
The Artificial Intelligence Imperative by Anastassia Lauterbach(1852)
Visualize Complex Processes with Microsoft Visio by David J Parker & Šenaj Lelić(1776)
The Old New Thing by Raymond Chen(1724)